var e = require("../../../utils/http.js"), t = getApp(),siteinfo = require("../../../siteinfo.js");

Page({
    data: {
        rank_id:0,
        host:siteinfo.siteroot,
        users: {},
        rank:{},
        items: {},
        images: {},
    },
    onLoad: function(e) {
        
    },
    onReady: function() {},
    onShow: function() {
        var a = this, o = this;
        this.taocan();
    },

    taocan: function() {
        var t = this;
        var userId = wx.getStorageSync("userId");
        e.post("/app/Dock/member_pack", {userId:userId}, !1, function(e) {
            console.log('e',e);
            t.setData({
              items: e.items,
              images: e.images,
              users: e.users,
              rank: e.rank,
              rank_id:e.users.rank_id
            });
        });
    },

    buy: function(t) {
      var _that = this;
      console.log('t',t);
      var rank_id = t.target.dataset.id;
      var userId = wx.getStorageSync("userId");
      e.post("/app/Dock/rank_buy", {rank_id:rank_id,userId:userId}, !1, function(e) {
        console.log('e',e);
        if(e.code==1){
          _that.doWxPay(e);
        }else{
          wx.showToast({
              title: '请稍后再试',
              icon:"none",
              mask:"true"
          })
        }
      });
    },
    doWxPay: function(o) {
      console.log('o',o);
      wx.requestPayment({
          timeStamp: o.timeStamp,
          nonceStr: o.nonceStr,
          package: o.package,
          signType: "MD5",
          paySign: o.paySign,
          success: function(o) {
              console.log(o), wx.showToast({
                  title: "支付成功",
                  icon: "none",
                  duration: 2e3,
                  success: function() {
                      wx.reLaunch({
                          url: "/pages/member/index/index"
                      });
                  }
              });
          },
          fail: function(o) {
              wx.showToast({
                  title: "支付失败",
                  icon: "none",
                  duration: 2e3
              }), console.log("支付失败");
          }
      });
    },
   
   
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
   
});